﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text;
namespace DTO
{
    public class LogFile
    {
        public static void writing(string path, string file, string className, string function, string error)
        {
            try
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                path = path + "\\" + DateTime.Now.ToString("yyyy_MM_dd");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                path = path + "\\" + file;
                FileStream fs = null;
                if (!File.Exists(path))
                {
                    fs = new FileStream(path, FileMode.CreateNew);
                }
                else
                {
                    fs = new FileStream(path, FileMode.Append);
                }
                using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
                {
                    String sError = "DateTime : " + DateTime.Now.ToString() + " className : " + className
                        + " function : " + function + "  " + error;
                    w.WriteLine(sError);
                    w.Close();
                    fs.Close();
                }
            }
            catch
            {
            }

        }
    }
}
